home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gas_251.zip / bin_251 / bfd / coff-m88k.c < prev    next >
C/C++ Source or Header  |  1994-10-04  |  5KB  |  152 lines

  1. /* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
  2.    Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  3.    Written by Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #define M88 1        /* Customize various include files */
  22. #include "bfd.h"
  23. #include "sysdep.h"
  24. #include "libbfd.h"
  25. #include "obstack.h"
  26. #include "coff/m88k.h"
  27. #include "coff/internal.h"
  28. #include "libcoff.h"
  29.  
  30. #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
  31.  
  32. #undef HOWTO_PREPARE
  33. /* Provided the symbol, returns the value reffed */
  34. #define HOWTO_PREPARE(relocation, symbol)     \
  35.   {                        \
  36.   if (symbol != (asymbol *)NULL) {        \
  37.     if (bfd_is_com_section (symbol->section)) { \
  38.       relocation = 0;                \
  39.     }                        \
  40.     else {                    \
  41.       relocation = symbol->value;        \
  42.     }                        \
  43.   }                        \
  44.   if (symbol->section != (asection *)NULL) {    \
  45.     relocation += symbol->section->output_section->vma +    \
  46.       symbol->section->output_offset;        \
  47.   }                        \
  48. }            
  49.  
  50.  
  51. static bfd_reloc_status_type 
  52. howto_hvrt16 (abfd, reloc_entry, symbol_in, data,
  53.             ignore_input_section, ignore_bfd, error_message)
  54.      bfd *abfd;
  55.      arelent *reloc_entry;
  56.      asymbol *symbol_in;
  57.      PTR data;
  58.      asection *ignore_input_section;
  59.      bfd *ignore_bfd;
  60.      char **error_message;
  61. {
  62.   long relocation = 0;
  63.   bfd_vma addr = reloc_entry->address;
  64.   long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
  65.  
  66.   HOWTO_PREPARE(relocation, symbol_in);
  67.  
  68.   x = (x + relocation + reloc_entry->addend) >> 16;
  69.  
  70.   bfd_put_16(abfd, x, (bfd_byte *)data + addr);
  71.   return bfd_reloc_ok;
  72. }
  73.  
  74.  
  75.  
  76. static reloc_howto_type howto_table[] = 
  77. {
  78.   HOWTO(R_PCR16L,02,1,16,true, 0,complain_overflow_signed, 0, "PCR16L",false,0x0000ffff,0x0000ffff,true),
  79.   HOWTO(R_PCR26L,02,2,26,true, 0,complain_overflow_signed, 0, "PCR26L",false,0x03ffffff,0x03ffffff,true),
  80.   HOWTO(R_VRT16, 00,1,16,false,0,complain_overflow_bitfield, 0, "VRT16", false,0x0000ffff,0x0000ffff,true),
  81.   HOWTO(R_HVRT16,16,1,16,false,0,complain_overflow_dont,howto_hvrt16,"HVRT16",false,0x0000ffff,0x0000ffff,true),
  82.   HOWTO(R_LVRT16,00,1,16,false,0,complain_overflow_dont, 0, "LVRT16",false,0x0000ffff,0x0000ffff,true),
  83.   HOWTO(R_VRT32, 00,2,32,false,0,complain_overflow_bitfield, 0, "VRT32", false,0xffffffff,0xffffffff,true),
  84. };
  85.  
  86.  
  87. /* Code to swap in the reloc offset */
  88. #define SWAP_IN_RELOC_OFFSET   bfd_h_get_16
  89. #define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
  90.  
  91.  
  92. /* Code to turn an external r_type into a pointer to an entry in the
  93.    above howto table */
  94. #define RTYPE2HOWTO(cache_ptr, dst)                    \
  95.         if ((dst)->r_type >= R_PCR16L && (dst)->r_type <= R_VRT32) {\
  96.         (cache_ptr)->howto = howto_table + (dst)->r_type - R_PCR16L;\
  97.         (cache_ptr)->addend += (dst)->r_offset << 16;        \
  98.         }                                \
  99.         else {                            \
  100.         BFD_ASSERT(0);                        \
  101.         }
  102.  
  103.  
  104.  
  105. #define BADMAG(x) MC88BADMAG(x)
  106. #include "coffcode.h"
  107.  
  108. #undef coff_write_armap
  109.  
  110. const bfd_target m88kbcs_vec =
  111. {
  112.   "coff-m88kbcs",        /* name */
  113.   bfd_target_coff_flavour,
  114.   true,                /* data byte order is big */
  115.   true,                /* header byte order is big */
  116.  
  117.   (HAS_RELOC | EXEC_P |        /* object flags */
  118.    HAS_LINENO | HAS_DEBUG |
  119.    HAS_SYMS | HAS_LOCALS | WP_TEXT),
  120.  
  121.   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
  122.   '_',                /* leading underscore */
  123.   '/',                /* ar_pad_char */
  124.   15,                /* ar_max_namelen */
  125.   3,                /* default alignment power */
  126.   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
  127.      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
  128.      bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
  129.   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
  130.      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
  131.      bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
  132.  
  133.     {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
  134.        bfd_generic_archive_p, _bfd_dummy_target},
  135.     {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
  136.        bfd_false},
  137.     {bfd_false, coff_write_object_contents, /* bfd_write_contents */
  138.        _bfd_write_archive_contents, bfd_false},
  139.  
  140.      BFD_JUMP_TABLE_GENERIC (coff),
  141.      BFD_JUMP_TABLE_COPY (coff),
  142.      BFD_JUMP_TABLE_CORE (_bfd_nocore),
  143.      BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
  144.      BFD_JUMP_TABLE_SYMBOLS (coff),
  145.      BFD_JUMP_TABLE_RELOCS (coff),
  146.      BFD_JUMP_TABLE_WRITE (coff),
  147.      BFD_JUMP_TABLE_LINK (coff),
  148.      BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
  149.  
  150.   COFF_SWAP_TABLE,
  151. };
  152.